package com.soilflow.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.soilflow.common.domain.ColorfulUser;
import com.soilflow.common.utils.DateUtils;
import com.soilflow.system.mapper.ColorfulUserMapper;
import com.soilflow.system.service.IColorfulUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author party
 * @date 2023-10-24
 */
@Service
public class ColorfulUserServiceImpl extends ServiceImpl<ColorfulUserMapper, ColorfulUser> implements IColorfulUserService {

    @Resource
    private ColorfulUserMapper colorfulUserMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param userId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public ColorfulUser selectColorfulUserByUserId(Long userId)
    {
        return colorfulUserMapper.selectColorfulUserByUserId(userId);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param colorfulUser 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<ColorfulUser> selectColorfulUserList(ColorfulUser colorfulUser)
    {
        return colorfulUserMapper.selectColorfulUserList(colorfulUser);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param colorfulUser 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertColorfulUser(ColorfulUser colorfulUser)
    {
        colorfulUser.setCreateTime(DateUtils.getNowDate());
        return colorfulUserMapper.insertColorfulUser(colorfulUser);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param colorfulUser 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateColorfulUser(ColorfulUser colorfulUser)
    {
        colorfulUser.setUpdateTime(DateUtils.getNowDate());
        return colorfulUserMapper.updateColorfulUser(colorfulUser);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param userIds 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteColorfulUserByUserIds(Long[] userIds)
    {
        return colorfulUserMapper.deleteColorfulUserByUserIds(userIds);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param userId 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteColorfulUserByUserId(Long userId)
    {
        return colorfulUserMapper.deleteColorfulUserByUserId(userId);
    }

    @Override
    public ColorfulUser selectUserByUserName(String username) {
        return this.baseMapper.selectUserByUserName(username);
    }

    @Override
    public ColorfulUser getPhonenumber(String phone) {
        LambdaQueryWrapper<ColorfulUser> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(ColorfulUser::getPhonenumber,phone);
        wrapper.eq(ColorfulUser::getDelFlag,0);
        wrapper.orderByDesc(ColorfulUser::getUserId);
        ColorfulUser user = this.getOne(wrapper);
        return user;
    }

}
